// component/button/dataset/datasetView.js
var app = getApp()
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        code: {
            type: String,
            value: ''
        },
        key: {
            type: String,
            value: ''
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        showTxt: ''
    },
    attached: function() {
        var that = this;
        // console.log("执行了attached")
        // var showTxt = app.dataDict[this.data.code][this.data.key]

        var showTxt = wx.getStorageSync("dataDrict")[that.data.code + "_" + that.data.key];

        if (!showTxt){
            showTxt = this.data.key
        }

        that.setData({
            showTxt: showTxt
        })

        console.info("数据字典：%s[%s] = %s", that.data.code, that.data.key, showTxt)

        // 下面是是测试的异步存储数据字典，不用关心
        // wx.getStorage({
        //     key: 'dataDrict',
        //     success: function(res) {
        //         // console.log("res = %o", res)
        //         var showTxt = res.data[that.data.code + "_" + that.data.key];
        //         console.log("从缓存中获取的数据为：" + showTxt)
        //         setTimeout(function(){
        //             that.setData({
        //                 showTxt: showTxt
        //             })
        //         },1000);
        //     }
        // })
        
    },

    /**
     * 组件的方法列表
     */
    methods: {
        
    }
})